export function stringFormatOfTime(str:String, type, separator:String) {
  if (type === 'time') {
    let hour = str.substring(0, 2);
    let min = str.substring(2, 4);
    let sec = str.substring(4, 6);
    return hour + separator + min + separator + sec;
  }
  else if (type === 'date') {
    let year = str.substring(0, 4);
    let month = str.substring(4, 6);
    let day = str.substring(6, 8);
    return year + separator + month + separator + day;
  }
}


export function getNowFormatDate(seperator:String) {
  let date = new Date();
  let year = date.getFullYear();
  let month = fillZero(date.getMonth() + 1);
  let strDate = fillZero(date.getDate());
  var currentdate = year + seperator + month + seperator + strDate;
  return currentdate;
}

export function getNowFormatDateAndTime(seperatorDate: String, seperatorTime: String) {
  let date = getNowFormatDate(seperatorDate);
  let time = new Date();
  let hour = fillZero(time.getHours());
  let minus = fillZero(time.getMinutes());
  let second = fillZero(time.getSeconds());
  return date + ' ' + hour + seperatorTime + minus + seperatorTime + second;
}

function fillZero(value) {
  if (value >= 0 && value <= 9) {
    value = "0" + value;
  }
  return value;
}